using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using sbMembership.Library.Presenters.ViewInterfaces;
using sbMembership.Library.Presenters;
using sbMembership.Library.Domain;

namespace sbMembership.Web.Views
{
    public partial class EditUserView : System.Web.UI.UserControl, IEditUserView
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region IEditUserView Members

        public string Message
        {
            set { throw new Exception("The method or operation is not implemented."); }
        }

        public sbUser UserToUpdate
        {
            get
            {
                sbUser updatedUser = new sbUser(txtUsername.Text, "", txtEmail.Text);
                return updatedUser;
            }
            set
            {
                if (value == null) throw new ArgumentNullException("User to edit may not be null");

                txtUsername.Text = value.UserName;
                txtEmail.Text = value.Email;
            }
        }

        EditUserPresenter presenter;
        public void AttachPresenter(EditUserPresenter presenter)
        {
            this.presenter = presenter;
        }

        #endregion

        protected void btnUpdateUserOK_Click(object sender, EventArgs e)
        {
            presenter.SaveUser();
        }
    }
}